package org.example.demo.SQL.Dao;

import org.example.demo.SQL.Models.User;

import java.util.HashMap;
import java.util.Map;

public class UserDao {
    private static Map<Integer, User> users = new HashMap<Integer, User>();
    static {
        users.put(1, new User(1,"张三","123456"));
        users.put(2, new User(2,"李四","123456"));
        users.put(3, new User(3,"王五","123456"));
    }

    // 查询所有用户
    public static Map<Integer, User> findAllUsers() { return users; }

    // 查询单个用户
    public static User findUserById(int id) { return users.get(id); }

    // 添加用户
    public static void addUser(User user) { users.put(user.getId(), user); }

    // 删除用户
    public static void deleteUserById(int id) { users.remove(id); }

    // 修改用户
    public static void updateUser(User user) { users.put(user.getId(), user); }

}
